package data.app
{
	import data.DataFactory;
	import data.app.packCode.MessagePackCode;
	import data.app.packCode.UserPackCode;
	import data.app.receive.message.MessageReceiveData;
	import data.app.receive.users.UserReceiveData;
	import data.events.DataEvent;
	import data.events.RequestBaseEvent;
	import data.request.RequestBase;

	/**
	 *数据返回工厂 
	 */	
	public class DataReceive
	{
		/**
		 *提示语数据返回
		 */		
		public var messageReceiveData:MessageReceiveData;
		
		/**
		 *用户基础数据返回 
		 */		
		public var userReceiveData:UserReceiveData;
		
		public function DataReceive()
		{
			register();
			setEvent();
		}
		
		/**
		 *数据返回对象注册 
		 */		
		private function register():void
		{
			messageReceiveData=new MessageReceiveData();
			userReceiveData=new UserReceiveData();
		}
		
		private function setEvent():void
		{
			DataFactory.Instance.dataReceive.addEventListener(DataEvent.SOCKET_DATA_RECEIVE, socketReceive);
			DataFactory.Instance.dataReceive.addEventListener(DataEvent.REQUEST_DATA_RECEIVE, requestReceive);
		}
		
		/**
		 * Socket数据返回
		 * @param object 数据
		 */
		private function socketReceive(evt:DataEvent):void
		{
			//根据数据根级编号来确定要驱动所对应的数据返回对象
			switch(evt.date.rootPackCode)
			{
				case MessagePackCode.ROOT_CODE://提示信息通讯数据
					messageReceiveData.dispatcher(evt.date);
					break;
				case UserPackCode.ROOT_CODE://用户通讯数据
					userReceiveData.dispatcher(evt.date);
					break;
			}
		}
		
		/**
		 * Request数据返回
		 * @param object 数据
		 */
		private function requestReceive(evt:DataEvent):void
		{
			//根据数据根级编号来确定要驱动所对应的数据返回对象
			switch(evt.date.rootPackCode)
			{
//				case MessagePackCode.ROOT_CODE://提示信息通讯数据
//					messageReceiveData.dispatcher(evt.date);
//					break;
//				case UserPackCode.ROOT_CODE://用户通讯数据
//					userReceiveData.dispatcher(evt.date);
//					break;
			}
		}		
	}
}